<!-- 消息详情 -->
<template>
	<view class="page">
		<template v-if="curentTab == 0">
			<view class="content">
				{{messageDetail && messageDetail.titile?messageDetail.titile:''}}
			</view>
			<view class="text" v-if="messageDetail.sender">
				<text>信息来源：</text>
				<text>{{messageDetail.sender}}</text>
			</view>
			<view class="time" v-if="messageDetail.sendTime">
				<text>发布时间：</text>
				<text>{{messageDetail.sendTime}}</text>
			</view>
			<view class="parase" v-if="messageDetail && messageDetail.msgContent">
				<u-parse style="white-space: break-word !important;word-break: break-all !important;" :content="messageDetail.msgContent"></u-parse>
				<!-- <rich-text :nodes="messageDetail.msgContent"></rich-text> -->
			</view>
		</template>
		<template v-else>
			<view class="content">
				{{messageDetail && messageDetail.title || messageDetail.titile }}
			</view>
			<view class="text" v-if="messageDetail.author || messageDetail.sender">
				<text>信息来源：</text>
				<text>{{messageDetail.author || messageDetail.sender}}</text>
			</view>
			<view class="time" v-if="messageDetail.createTime">
				<text>发布时间：</text>
				<text>{{messageDetail.createTime}}</text>
			</view>
			<!-- <view v-if="messageDetail.imageHref && messageDetail.type != 'url'" style="display: flex;align-items: center;justify-content: center;">
				<image :src="imageUrl(messageDetail.imageHref)" mode="aspectFill"></image>
			</view> -->
			<view class="parase" v-if="messageDetail && messageDetail.content && messageDetail.type == 'article'">
				<u-parse style="white-space: break-word !important;word-break: break-all !important;" :content="messageDetail.content"></u-parse>
				<!-- <rich-text :nodes="messageDetail.content"></rich-text> -->
			</view>
			<view v-if="messageDetail.fileUrl && messageDetail.type == 'file'">
				<view v-if="messageDetail.summary">{{ messageDetail.summary }}</view>
				<fileList :fileList="messageDetail.fileUrl"></fileList>
			</view>
			<view @click="onWebview(messageDetail)" v-if="messageDetail.type == 'url'">
				<view v-if="messageDetail.summary">{{ messageDetail.summary }}</view>
				<view v-if="messageDetail.imageHref" style="display: flex;align-items: center;justify-content: center;">
					<image :src="imageUrl(messageDetail.imageHref)" mode="aspectFill"></image>
				</view>
				<a style="color: #1E6FFF;">{{messageDetail.linkUrl}}</a>
			</view>
			
		</template>
	</view>
</template>

<script>
	import {
		messageInfoReadId, // 消息已读
	} from '../../api/index.js'
	import fileList from '../synergy/components/fileList.vue'
	import {imageUrl} from '@/utils/common.js'
	export default {
		data() {
			return {
				id: '', // 详情id
				messageDetail: '', // 消息详情
				curentTab: 0,
				imageUrl: imageUrl
			}
		},
		components: {
			fileList
		},
		onLoad(options) {
			if (options.item) {
				let str = decodeURIComponent(options.item)
				this.messageDetail = JSON.parse(str)
			}
			
			this.curentTab = options.index || 0
			// this.getDetail() // 获取消息详情
			this.getRead() // 获取消息详情已读
		},
		methods: {
			
			getRead () {
				var params = {
					anntId: this.messageDetail.anntId || this.messageDetail.id
				}
				messageInfoReadId(params).then(res => {
					if (res.success) {
						// this.messageDetail = res.result
					}
				}).catch(res => {
					
				})
			},
			
			onWebview (item) {
				// let url = 'https://www.baidu.com'
				// 以百度url为例子，具体填写你自己要跳转的链接 
				if (!item.linkUrl) {
					return false
				}
				uni.navigateTo({
				url: '/pages/webview/webview?url=' + item.linkUrl + '&officePreviewType=pdf'
				})
			}
			
			
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #FFFFFF;
	}
.page{
	padding: 40rpx;
	.content{
		text-align: center;
		font-size: 16px;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 600;
		color: #171717;
		// margin-top: 30rpx;
	}
	.text{
		margin-top: 32rpx;
		font-size: 14px;
		font-family: PingFangSC-Light, PingFang SC;
		font-weight: 300;
		color: #7F7F7F;
	}
	.time{
		margin: 8rpx 0 32rpx 0;
		font-size: 14px;
		font-family: PingFangSC-Light, PingFang SC;
		font-weight: 300;
		color: #7F7F7F;
	}
	.parase{
		// font-size: 16px;
		// width: 750rpx;
		white-space: normal;
	}
}
</style>
